package com.burstly.lib.component.networkcomponent.admob;

import com.burstly.lib.component.networkcomponent.AbstractNetworkConfigurator;
import com.burstly.lib.util.LoggerExt;
import com.burstly.lib.util.Utils;
import com.google.ads.AdRequest;
import com.google.ads.AdRequest.Gender;
import com.google.ads.AdSize;
import com.google.ads.mediation.admob.AdMobAdapterExtras;
import java.util.Arrays;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

class AdmobConfigurator extends AbstractNetworkConfigurator<AdRequest>
{
  public static final String BANNER_300X250 = "300x250";
  public static final String BANNER_468X60 = "468x60";
  public static final String BANNER_728X90 = "728x90";
  public static final String BANNER_SMART = "smart";
  private static final LoggerExt LOG = LoggerExt.getInstance();
  private static final String TAG = AdmobConfigurator.class.getSimpleName();
  private String mAdPubId;
  private AdSize mAdSize;
  private Date mBirthday;
  private Map<String, ?> mCustomNetworkParams;
  private String mDeviceTestId;
  private Map<String, Object> mExtras;
  private AdRequest.Gender mGender;
  private boolean mIsInterstitial;
  private boolean mIsPrefetchInterstitial;
  private Set<String> mKeyWords;
  private boolean mSuppressAdmobAutorefresh;

  static AdSize getAdSize(String paramString)
  {
    if ("300x250".equalsIgnoreCase(paramString))
      return AdSize.IAB_MRECT;
    if ("468x60".equalsIgnoreCase(paramString))
      return AdSize.IAB_BANNER;
    if ("728x90".equalsIgnoreCase(paramString))
      return AdSize.IAB_LEADERBOARD;
    if ("smart".equalsIgnoreCase(paramString))
      return AdSize.SMART_BANNER;
    return AdSize.BANNER;
  }

  private void mergeExtrasMaps(Map<String, Object> paramMap1, Map<String, Object> paramMap2)
  {
    if ((paramMap2 == null) || (paramMap1 == null) || (paramMap2.size() == 0));
    while (true)
    {
      return;
      Iterator localIterator1 = paramMap2.entrySet().iterator();
      while (localIterator1.hasNext())
      {
        Map.Entry localEntry1 = (Map.Entry)localIterator1.next();
        String str = (String)localEntry1.getKey();
        Object localObject = localEntry1.getValue();
        Iterator localIterator2 = paramMap1.entrySet().iterator();
        while (localIterator2.hasNext())
        {
          Map.Entry localEntry2 = (Map.Entry)localIterator2.next();
          if (str.equalsIgnoreCase((String)localEntry2.getKey()))
            localEntry2.setValue(localObject);
        }
        if (!paramMap1.containsKey(str))
          paramMap1.put(str, localObject);
      }
    }
  }

  private void setAdSize(Map<String, ?> paramMap)
  {
    this.mAdSize = getAdSize((String)paramMap.get("adSizeCodeValue"));
    Object localObject = paramMap.get("adSize");
    if (localObject != null)
      this.mAdSize = getAdSize((String)localObject);
  }

  private void setBirthday(Map<String, ?> paramMap)
  {
    String str1 = (String)paramMap.get("birthday");
    if (str1 != null)
    {
      this.mBirthday = Utils.getDateFromString(str1, "dd-MM-yyyy");
      LoggerExt localLoggerExt = LOG;
      String str2 = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mBirthday;
      localLoggerExt.logDebug(str2, "AdMob birthday param: {0}", arrayOfObject);
    }
  }

  private void setExtrasParams(Map<String, ?> paramMap)
  {
    int i;
    if ((this.mCustomNetworkParams != null) && (this.mCustomNetworkParams.containsKey("extras")))
    {
      i = 1;
      Object localObject = paramMap.get("extras");
      if (localObject == null)
        break label109;
      LOG.logDebug(TAG, "AdMob server extras params: {0}", new Object[] { localObject });
      localMap1 = (Map)localObject;
      if (i == 0)
        break label102;
      localMap2 = (Map)this.mCustomNetworkParams.get("extras");
      mergeExtrasMaps(localMap2, localMap1);
      this.mExtras = localMap2;
    }
    label102: label109: 
    while (i == 0)
    {
      Map localMap1;
      Map localMap2;
      return;
      i = 0;
      break;
      this.mExtras = localMap1;
      return;
    }
    this.mExtras = ((Map)this.mCustomNetworkParams.get("extras"));
  }

  private void setGender(Map<String, ?> paramMap)
  {
    String str1 = (String)paramMap.get("gender");
    if (str1 != null)
      if (!str1.equalsIgnoreCase("male"))
        break label71;
    label71: for (AdRequest.Gender localGender = AdRequest.Gender.MALE; ; localGender = AdRequest.Gender.FEMALE)
    {
      this.mGender = localGender;
      LoggerExt localLoggerExt = LOG;
      String str2 = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mGender;
      localLoggerExt.logDebug(str2, "AdMob gender param: {0}", arrayOfObject);
      return;
    }
  }

  private void setInterstitial(Map<String, ?> paramMap)
  {
    Object localObject1 = paramMap.get("isCodeValueInterstitial");
    if (localObject1 != null)
      this.mIsInterstitial = ((Boolean)localObject1).booleanValue();
    Object localObject2 = paramMap.get("isInterstitial");
    if (localObject2 != null)
      this.mIsInterstitial = "YES".equalsIgnoreCase((String)localObject2);
  }

  private void setKeyWords(Map<String, ?> paramMap)
  {
    String str1 = (String)paramMap.get("keyWords");
    if ((str1 != null) && (str1.length() > 0))
    {
      String[] arrayOfString = str1.split(";");
      this.mKeyWords = new HashSet((int)(arrayOfString.length / 0.75F));
      this.mKeyWords.addAll(Arrays.asList(arrayOfString));
      LoggerExt localLoggerExt = LOG;
      String str2 = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mKeyWords;
      localLoggerExt.logDebug(str2, "AdMob keywords param: {0}", arrayOfObject);
    }
  }

  protected void applyClientTargetingParamsToNetwork(Map<String, String> paramMap)
  {
    this.mBirthday = Utils.getDateFromString((String)paramMap.get("dateOfBirth"), "dd-MM-yyyy");
    Object localObject1 = paramMap.get("gender");
    this.mGender = AdRequest.Gender.UNKNOWN;
    if (localObject1 != null)
    {
      if (!localObject1.equals("male"))
        break label115;
      this.mGender = AdRequest.Gender.MALE;
    }
    while (true)
    {
      Object localObject2 = paramMap.get("keyWords");
      if (localObject2 != null)
      {
        String[] arrayOfString = ((String)localObject2).split(" ");
        this.mKeyWords = new HashSet((int)(arrayOfString.length / 0.75F));
        this.mKeyWords.addAll(Arrays.asList(arrayOfString));
      }
      return;
      label115: if (localObject1.equals("female"))
        this.mGender = AdRequest.Gender.FEMALE;
    }
  }

  public void configure(AdRequest paramAdRequest)
  {
    if (this.mBirthday != null)
      paramAdRequest.setBirthday(this.mBirthday);
    if (this.mGender != null)
      paramAdRequest.setGender(this.mGender);
    if (this.mKeyWords != null)
      paramAdRequest.setKeywords(this.mKeyWords);
    if (this.mDeviceTestId != null)
    {
      paramAdRequest.addTestDevice(this.mDeviceTestId);
      paramAdRequest.setTesting(true);
    }
    if (this.mExtras != null)
    {
      AdMobAdapterExtras localAdMobAdapterExtras = new AdMobAdapterExtras();
      localAdMobAdapterExtras.setExtras(this.mExtras);
      paramAdRequest.setNetworkExtras(localAdMobAdapterExtras);
    }
  }

  String getAdPubId()
  {
    return this.mAdPubId;
  }

  AdSize getAdSize()
  {
    return this.mAdSize;
  }

  boolean isInterstitial()
  {
    return this.mIsInterstitial;
  }

  boolean isPrefetchInterstitial()
  {
    return this.mIsPrefetchInterstitial;
  }

  boolean isSuppressAdmobAutorefresh()
  {
    return this.mSuppressAdmobAutorefresh;
  }

  public void readParameters(Map<String, ?> paramMap)
    throws IllegalArgumentException
  {
    applyClientTargetingIfAllowed(paramMap);
    this.mAdPubId = ((String)paramMap.get("pubID"));
    Utils.checkNotNull(this.mAdPubId, "pubID can not be null");
    this.mAdPubId = this.mAdPubId.trim();
    setInterstitial(paramMap);
    setAdSize(paramMap);
    this.mSuppressAdmobAutorefresh = Boolean.valueOf((String)paramMap.get("supressAutorefresh")).booleanValue();
    this.mDeviceTestId = ((String)paramMap.get("testDeviceId"));
    if (this.mDeviceTestId != null)
    {
      LoggerExt localLoggerExt = LOG;
      String str = TAG;
      Object[] arrayOfObject = new Object[1];
      arrayOfObject[0] = this.mDeviceTestId;
      localLoggerExt.logInfo(str, "AdMob testing mode enabled. Device test id: {0}", arrayOfObject);
    }
    Object localObject = paramMap.get("admob");
    if (localObject != null)
      this.mCustomNetworkParams = ((Map)localObject);
    this.mKeyWords = null;
    this.mGender = null;
    this.mExtras = null;
    setBirthday(paramMap);
    setGender(paramMap);
    setKeyWords(paramMap);
    setExtrasParams(paramMap);
  }

  void setPrefetchInterstitial(boolean paramBoolean)
  {
    this.mIsPrefetchInterstitial = paramBoolean;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.admob.AdmobConfigurator
 * JD-Core Version:    0.6.2
 */